home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / xceedzip / xceedzip.exe / Samples / Zip Manager / Vb6 / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-04-27  |  34.6 KB  |  745 lines

  1. VERSION 5.00
  2. Object = "{DB797681-40E0-11D2-9BD5-0060082AE372}#4.1#0"; "XceedZip.dll"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  4. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  5. Begin VB.Form frmMain 
  6.    Caption         =   "Zip Manager Sample Application (Xceed Zip v4.0)"
  7.    ClientHeight    =   5415
  8.    ClientLeft      =   2580
  9.    ClientTop       =   1515
  10.    ClientWidth     =   8775
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   361
  14.    ScaleMode       =   3  'Pixel
  15.    ScaleWidth      =   585
  16.    Begin VB.PictureBox picStatus 
  17.       Align           =   2  'Align Bottom
  18.       Height          =   315
  19.       Left            =   0
  20.       ScaleHeight     =   17
  21.       ScaleMode       =   3  'Pixel
  22.       ScaleWidth      =   581
  23.       TabIndex        =   0
  24.       TabStop         =   0   'False
  25.       Top             =   5100
  26.       Width           =   8775
  27.       Begin MSComctlLib.ProgressBar prbGlobalProgress 
  28.          Height          =   255
  29.          Left            =   6120
  30.          TabIndex        =   3
  31.          Top             =   0
  32.          Visible         =   0   'False
  33.          Width           =   1770
  34.          _ExtentX        =   3122
  35.          _ExtentY        =   450
  36.          _Version        =   393216
  37.          BorderStyle     =   1
  38.          Appearance      =   0
  39.       End
  40.       Begin VB.CommandButton cmdAbort 
  41.          Caption         =   "&Abort"
  42.          Enabled         =   0   'False
  43.          Height          =   260
  44.          Left            =   7980
  45.          TabIndex        =   1
  46.          Top             =   0
  47.          Width           =   735
  48.       End
  49.       Begin VB.Label lblProgress 
  50.          Caption         =   "Progress:"
  51.          Height          =   255
  52.          Left            =   5400
  53.          TabIndex        =   4
  54.          Top             =   30
  55.          Visible         =   0   'False
  56.          Width           =   735
  57.       End
  58.       Begin VB.Label lblStatusBar 
  59.          Caption         =   "No zip file currently opened."
  60.          Height          =   255
  61.          Left            =   45
  62.          TabIndex        =   2
  63.          Top             =   30
  64.          Width           =   5220
  65.       End
  66.    End
  67.    Begin MSComDlg.CommonDialog dlgSelectFiles 
  68.       Left            =   8400
  69.       Top             =   8280
  70.       _ExtentX        =   847
  71.       _ExtentY        =   847
  72.       _Version        =   393216
  73.    End
  74.    Begin MSComDlg.CommonDialog dlgSelectZip 
  75.       Left            =   8880
  76.       Top             =   8280
  77.       _ExtentX        =   847
  78.       _ExtentY        =   847
  79.       _Version        =   393216
  80.    End
  81.    Begin MSComctlLib.ListView lstMain 
  82.       Height          =   4575
  83.       Left            =   0
  84.       TabIndex        =   5
  85.       Top             =   0
  86.       Width           =   7935
  87.       _ExtentX        =   13996
  88.       _ExtentY        =   8070
  89.       View            =   3
  90.       Arrange         =   2
  91.       LabelEdit       =   1
  92.       MultiSelect     =   -1  'True
  93.       LabelWrap       =   -1  'True
  94.       HideSelection   =   0   'False
  95.       FullRowSelect   =   -1  'True
  96.       TextBackground  =   -1  'True
  97.       _Version        =   393217
  98.       ForeColor       =   0
  99.       BackColor       =   -2147483643
  100.       Appearance      =   1
  101.       NumItems        =   12
  102.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  103.          Text            =   "Name"
  104.          Object.Width           =   2646
  105.       EndProperty
  106.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  107.          SubItemIndex    =   1
  108.          Text            =   "Comment"
  109.          Object.Width           =   2469
  110.       EndProperty
  111.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  112.          SubItemIndex    =   2
  113.          Text            =   "Size"
  114.          Object.Width           =   1323
  115.       EndProperty
  116.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  117.          SubItemIndex    =   3
  118.          Text            =   "Packed"
  119.          Object.Width           =   1323
  120.       EndProperty
  121.       BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  122.          SubItemIndex    =   4
  123.          Text            =   "Attributes"
  124.          Object.Width           =   1429
  125.       EndProperty
  126.       BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  127.          SubItemIndex    =   5
  128.          Text            =   "CRC"
  129.          Object.Width           =   1984
  130.       EndProperty
  131.       BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  132.          SubItemIndex    =   6
  133.          Text            =   "Last Modified"
  134.          Object.Width           =   3175
  135.       EndProperty
  136.       BeginProperty ColumnHeader(8) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  137.          SubItemIndex    =   7
  138.          Text            =   "Last Accessed"
  139.          Object.Width           =   3175
  140.       EndProperty
  141.       BeginProperty ColumnHeader(9) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  142.          SubItemIndex    =   8
  143.          Text            =   "Created"
  144.          Object.Width           =   3175
  145.       EndProperty
  146.       BeginProperty ColumnHeader(10) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  147.          SubItemIndex    =   9
  148.          Text            =   "Path"
  149.          Object.Width           =   2646
  150.       EndProperty
  151.       BeginProperty ColumnHeader(11) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  152.          SubItemIndex    =   10
  153.          Text            =   "Method"
  154.          Object.Width           =   1323
  155.       EndProperty
  156.       BeginProperty ColumnHeader(12) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  157.          SubItemIndex    =   11
  158.          Text            =   "Encrypted"
  159.          Object.Width           =   1852
  160.       EndProperty
  161.    End
  162.    Begin XceedZipLibCtl.XceedZip xZip 
  163.       Left            =   8160
  164.       Top             =   4440
  165.       BasePath        =   ""
  166.       CompressionLevel=   6
  167.       EncryptionPassword=   ""
  168.       RequiredFileAttributes=   0
  169.       ExcludedFileAttributes=   24
  170.       FilesToProcess  =   ""
  171.       FilesToExclude  =   ""
  172.       MinDateToProcess=   2
  173.       MaxDateToProcess=   2958465
  174.       MinSizeToProcess=   0
  175.       MaxSizeToProcess=   0
  176.       SplitSize       =   0
  177.       PreservePaths   =   -1  'True
  178.       ProcessSubfolders=   0   'False
  179.       SkipIfExisting  =   0   'False
  180.       SkipIfNotExisting=   0   'False
  181.       SkipIfOlderDate =   0   'False
  182.       SkipIfOlderVersion=   0   'False
  183.       TempFolder      =   ""
  184.       UseTempFile     =   -1  'True
  185.       UnzipToFolder   =   ""
  186.       ZipFilename     =   ""
  187.       SpanMultipleDisks=   2
  188.       ExtraHeaders    =   10
  189.       ZipOpenedFiles  =   0   'False
  190.       BackgroundProcessing=   0   'False
  191.       SfxBinrayModule =   ""
  192.       SfxDefaultPassword=   ""
  193.       SfxDefaultUnzipToFolder=   ""
  194.       SfxExistingFileBehavior=   0
  195.       SfxReadmeFile   =   ""
  196.       SfxExecuteAfter =   ""
  197.       SfxInstallMode  =   0   'False
  198.       SfxProgramGroup =   ""
  199.       SfxProgramGroupItems=   ""
  200.       SfxExtensionsToAssociate=   ""
  201.       SfxIconFilename =   ""
  202.    End
  203.    Begin VB.Menu mnuFile 
  204.       Caption         =   "&File"
  205.       Begin VB.Menu mnuFileNew 
  206.          Caption         =   "&New Zip File"
  207.       End
  208.       Begin VB.Menu mnuFileOpen 
  209.          Caption         =   "&Open Zip File"
  210.       End
  211.       Begin VB.Menu mnuFileLine1 
  212.          Caption         =   "-"
  213.       End
  214.       Begin VB.Menu mnuFileSettings 
  215.          Caption         =   "&Options..."
  216.       End
  217.       Begin VB.Menu mnuFileLine2 
  218.          Caption         =   "-"
  219.       End
  220.       Begin VB.Menu mnuFileColConfig 
  221.          Caption         =   "&Column settings..."
  222.       End
  223.       Begin VB.Menu mnuFileLine3 
  224.          Caption         =   "-"
  225.       End
  226.       Begin VB.Menu mnuFileExit 
  227.          Caption         =   "&Exit"
  228.       End
  229.    End
  230.    Begin VB.Menu mnuActions 
  231.       Caption         =   "&Actions"
  232.       Begin VB.Menu mnuActionsAdd 
  233.          Caption         =   "&Add files..."
  234.       End
  235.       Begin VB.Menu mnuActionsExtract 
  236.          Caption         =   "&Unzip files..."
  237.       End
  238.       Begin VB.Menu mnuActionsLine1 
  239.          Caption         =   "-"
  240.       End
  241.       Begin VB.Menu mnuActionsRemove 
  242.          Caption         =   "&Delete file(s)..."
  243.       End
  244.       Begin VB.Menu mnuActionsTest 
  245.          Caption         =   "&Test zip file"
  246.       End
  247.    End
  248.    Begin VB.Menu mnuHelp 
  249.       Caption         =   "&Help"
  250.       Begin VB.Menu mnuHelpAbout 
  251.          Caption         =   "&About the Zip Manager Sample Application..."
  252.       End
  253.    End
  254. Attribute VB_Name = "frmMain"
  255. Attribute VB_GlobalNameSpace = False
  256. Attribute VB_Creatable = False
  257. Attribute VB_PredeclaredId = True
  258. Attribute VB_Exposed = False
  259. Option Explicit
  260. ' ===================================================================
  261. '    DESCRIPTION:  Zip Manager Sample Application for VB6
  262. '    COPYRIGHT:    Copyright 
  263. 1995-1999 Xceed Software Inc.
  264. '                  All Rights Reserved.
  265. ' ===================================================================
  266. '------------------------------------------------------------------------------------
  267. ' Update the list view with the contents of the current zip file.
  268. '------------------------------------------------------------------------------------
  269. Private Sub UpdateZipContentsList()
  270.     Dim xErr As xcdError
  271.     lstMain.ListItems.Clear
  272.     If Len(xZip.ZipFilename) = 0 Then
  273.         Caption = "Zip Manager Sample Application (Xceed Zip 4)"
  274.     Else
  275.         DisableInterface
  276.         Load frmResults
  277.         xZip.FilesToProcess = ""
  278.         lstMain.Visible = False
  279.         xErr = xZip.ListZipContents
  280.         lstMain.Visible = True
  281.         If frmResults.HasMessages Then
  282.             frmResults.Show vbModal
  283.         End If
  284.         Unload frmResults
  285.         
  286.         If (xErr = xerSuccess) Or (xErr = xerWarnings) Or (xErr = xerFilesSkipped) Then
  287.             lblStatusBar.Caption = xZip.ZipFilename & " opened."
  288.             Caption = xZip.ZipFilename & " - Zip Manager Sample Application (Xceed Zip 4)"
  289.         Else
  290.             lblStatusBar.Caption = "Could not read " & xZip.ZipFilename
  291.             xZip.ZipFilename = ""
  292.             Caption = "Zip Manager Sample Application (Xceed Zip 4)"
  293.         End If
  294.     End If
  295.     EnableInterface
  296. End Sub
  297. '------------------------------------------------------------------------------------
  298. 'Aborts the current operation
  299. '------------------------------------------------------------------------------------
  300. Private Sub cmdAbort_Click()
  301.     xZip.Abort = True
  302. End Sub
  303. '------------------------------------------------------------------------------------
  304. ' Stores the initial position of various objects for resizing purposes and
  305. ' disables some menu items
  306. '------------------------------------------------------------------------------------
  307. Private Sub Form_Load()
  308.     ' Enable or disable based on initial setup
  309.     UpdateZipContentsList
  310. End Sub
  311. '------------------------------------------------------------------------------------
  312. ' When the form is resized, the objects on it must be repositionned in order
  313. ' to stay in their correct locations
  314. '------------------------------------------------------------------------------------
  315. Private Sub Form_Resize()
  316.     lstMain.Width = frmMain.ScaleWidth
  317.     lstMain.Height = frmMain.ScaleHeight - picStatus.Height
  318.     ' Since the picture box is not yet resized, we use the form's dimensions
  319.     cmdAbort.Left = frmMain.ScaleWidth - cmdAbort.Width - 4
  320. End Sub
  321. '------------------------------------------------------------------------------------
  322. ' The "Action" main menu is selected. We update the state of the "Remove files..."
  323. ' submenu depending if files are selected
  324. '------------------------------------------------------------------------------------
  325. Private Sub mnuActions_Click()
  326.     Dim i As Integer
  327.     For i = 1 To lstMain.ListItems.Count
  328.         If lstMain.ListItems(i).Selected Then
  329.             mnuActionsRemove.Enabled = True
  330.             Exit Sub
  331.         End If
  332.     Next i
  333.     mnuActionsRemove.Enabled = False
  334. End Sub
  335. '------------------------------------------------------------------------------------
  336. ' "Actions -> Add files..." has been choosen in the menu. Open the frmZip dialog
  337. ' that will let the user select what and how to zip.
  338. '------------------------------------------------------------------------------------
  339. Private Sub mnuActionsAdd_Click()
  340.     Dim xErr As xcdError
  341.     Load frmZip
  342.     If frmZip.ShowForm(xZip) Then
  343.         DisableInterface
  344.         Load frmResults
  345.         lblStatusBar.Caption = "Scanning files to zip..."
  346.         xErr = xZip.Zip
  347.         frmResults.Show vbModal
  348.         Unload frmResults
  349.         EnableInterface
  350.         
  351.         ' Update the zip contents list
  352.         UpdateZipContentsList
  353.     End If
  354.     Unload frmZip
  355. End Sub
  356. '------------------------------------------------------------------------------------
  357. ' "Actions -> Unzip files..." has been choosen in the menu. The frmUnzip
  358. ' and the FrmResults (event log) will we loaded and the unzipping
  359. ' operation will be started if the ShowUnzipOptions function returns TRUE.
  360. '------------------------------------------------------------------------------------
  361. Private Sub mnuActionsExtract_Click()
  362.     Dim xErr As xcdError
  363.         
  364.     Load frmUnzip
  365.     If frmUnzip.ShowForm(xZip, lstMain.ListItems) Then
  366.         DisableInterface
  367.         Load frmResults
  368.         lblStatusBar.Caption = "Reading zip file..."
  369.         xErr = xZip.Unzip
  370.         frmResults.Show vbModal
  371.         Unload frmResults
  372.         EnableInterface
  373.         
  374.         ' No need to update the interface
  375.     End If
  376.     Unload frmUnzip
  377. End Sub
  378. '------------------------------------------------------------------------------------
  379. ' "Actions -> Remove files..." has been choosen in the menu. If the
  380. ' LoadRemoveFiles function returns TRUE, it means that the user
  381. ' confirmed that files should be deleted, and so the FrmResults (event log)
  382. ' is we loaded and the Xceed Zip object's RemoveFiles method will be called.
  383. '------------------------------------------------------------------------------------
  384. Private Sub mnuActionsRemove_Click()
  385.     Dim xErr As xcdError
  386.     If ConfirmRemoveFiles Then
  387.         DisableInterface
  388.         Load frmResults
  389.         xErr = xZip.RemoveFiles
  390.         frmResults.Show vbModal
  391.         Unload frmResults
  392.         EnableInterface
  393.         
  394.         UpdateZipContentsList
  395.     End If
  396. End Sub
  397. '------------------------------------------------------------------------------------
  398. ' "Actions -> Test" has been chosen in the menu. This sub. will call the
  399. ' TestZipFile method. The TestingFile event will alert if errors are found.
  400. '------------------------------------------------------------------------------------
  401. Private Sub mnuActionsTest_Click()
  402.     Dim xErr As xcdError
  403.     DisableInterface
  404.     Load frmResults
  405.     xErr = xZip.TestZipFile
  406.     frmResults.Show vbModal
  407.     Unload frmResults
  408.     EnableInterface
  409. End Sub
  410. '------------------------------------------------------------------------------------
  411. ' "File -> Column settings" has been chosen in the menu. The
  412. ' frmSettingsColumns form will be shown.
  413. '------------------------------------------------------------------------------------
  414. Private Sub mnuFileColConfig_Click()
  415.     Load frmOptionsColumns
  416.     frmOptionsColumns.ShowForm xZip
  417.     Unload frmOptionsColumns
  418. End Sub
  419. '------------------------------------------------------------------------------------
  420. ' End of program
  421. '------------------------------------------------------------------------------------
  422. Private Sub mnuFileExit_Click()
  423.     Unload Me
  424. End Sub
  425. '------------------------------------------------------------------------------------
  426. ' "File -> New zip file" has been chosen in the menu. A dialog box will be
  427. ' opened to allow the user to specify the zip file's name and location. Once
  428. ' that has been done, the sample application's AddFiles function will be called,
  429. ' which will allow the user to specify files to add into the zip file right away.
  430. '------------------------------------------------------------------------------------
  431. Private Sub mnuFileNew_Click()
  432.     Dim sZipFilename As String
  433.        
  434.     sZipFilename = SelectZipFile(NewZip) ' Open a dialog to select the Zip file
  435.     If Len(sZipFilename) > 0 Then
  436.         ' The SelectZipFile dialog already warns the user about the
  437.         ' already existing zip file, so we can delete it if it exists
  438.         If Len(Dir(sZipFilename)) > 0 Then
  439.             Kill sZipFilename
  440.         End If
  441.         
  442.         ' Clear the list and update the view
  443.         UpdateZipContentsList
  444.         
  445.         ' Update current zip file
  446.         xZip.ZipFilename = sZipFilename
  447.         
  448.         ' Fake an adding command
  449.         mnuActionsAdd_Click
  450.    End If
  451. End Sub
  452. '------------------------------------------------------------------------------------
  453. ' "File -> Open zip file" has been chosen in the menu. A dialog box is
  454. ' displayed to allow the user to specify the name and location of the
  455. ' zip file to open. If any errors occur, a message box will be shown.
  456. '------------------------------------------------------------------------------------
  457. Private Sub mnuFileOpen_Click()
  458.     Dim sZipFilename As String
  459.     sZipFilename = SelectZipFile(OpenZip) ' Open a dialog to select the Zip file
  460.     If Len(sZipFilename) > 0 Then
  461.         xZip.ZipFilename = sZipFilename
  462.         
  463.         ' Update the zip contents list
  464.         UpdateZipContentsList
  465.     End If
  466. End Sub
  467. '------------------------------------------------------------------------------------
  468. ' "File -> Options..." has been chosen in the menu. The options window will
  469. ' shown.
  470. '------------------------------------------------------------------------------------
  471. Private Sub mnuFileSettings_Click()
  472.     Load frmOptions
  473.     frmOptions.ShowForm xZip
  474.     Unload frmOptions
  475. End Sub
  476. '------------------------------------------------------------------------------------
  477. ' "Help -> About" has been chosen in the menu. The copyright notice will be
  478. ' displayed.
  479. '------------------------------------------------------------------------------------
  480. Private Sub mnuHelpAbout_Click()
  481.     MsgBox "Zip Manager Sample Application for VB6" & vbCrLf & _
  482.            "For the Xceed Zip Compression Library v4.0" & vbCrLf & _
  483.            "Copyright 1995-1999 Xceed Software, All Rights Reserved", vbInformation
  484. End Sub
  485. '------------------------------------------------------------------------------------
  486. ' FileStatus event. This event is triggered when zipping, unzipping, testing, etc.
  487. ' It allows you to show how much of the current file has actually been processed.
  488. ' It also allows you to (as we show here) to find out when a file is actually
  489. ' being zipped or unzipped. This event is triggered once for every 32K processed.
  490. '------------------------------------------------------------------------------------
  491. Private Sub xZip_FileStatus(ByVal sFilename As String, ByVal lSize As Long, _
  492.                             ByVal lCompressedSize As Long, ByVal lBytesProcessed As Long, _
  493.                             ByVal nBytesPercent As Integer, ByVal nCompressionRatio As Integer, _
  494.                             ByVal bFileCompleted As Boolean)
  495.     Select Case xZip.CurrentOperation
  496.     Case xcoZipping
  497.         lblStatusBar.Caption = "Zipping file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  498.     Case xcoUnzipping
  499.         lblStatusBar.Caption = "Unzipping file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  500.     Case xcoTestingZipFile
  501.         lblStatusBar.Caption = "Testing file " & sFilename & " (" & CStr(nBytesPercent) & "%)"
  502.     Case xcoRemoving
  503.         lblStatusBar.Caption = "Removing file " & sFilename
  504.     End Select
  505. End Sub
  506. '------------------------------------------------------------------------------------
  507. ' GlobalStatus event. This event is triggered throughout operations such as
  508. ' zipping, unzipping, deleting files, etc. It provides progress information
  509. ' and statistics for the current operation. Our implementation here uses
  510. ' GlobalStatus to update the Global Progress bar underneat the main listbox.
  511. '------------------------------------------------------------------------------------
  512. Private Sub xZip_GlobalStatus(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long, _
  513.                               ByVal lFilesSkipped As Long, ByVal nFilesPercent As Integer, _
  514.                               ByVal lBytesTotal As Long, ByVal lBytesProcessed As Long, _
  515.                               ByVal lBytesSkipped As Long, ByVal nBytesPercent As Integer, _
  516.                               ByVal lBytesOutput As Long, ByVal nCompressionRatio As Integer)
  517.     prbGlobalProgress.Value = nBytesPercent
  518. End Sub
  519. '------------------------------------------------------------------------------------
  520. ' The InsertDisk event is triggered when another disk is required when reading
  521. ' or writing spanned zip files.
  522. '------------------------------------------------------------------------------------
  523. Private Sub xZip_InsertDisk(ByVal lDiskNumber As Long, bDiskInserted As Boolean)
  524.     Dim xAnswer As VbMsgBoxResult
  525.     If lDiskNumber = 0 Then
  526.         xAnswer = MsgBox("This zip file is part of a multiple disks zip file. Please insert the last disk of the set.", vbInformation + vbOKCancel)
  527.     Else
  528.         xAnswer = MsgBox("Please insert disk #" & CStr(lDiskNumber), vbInformation + vbOKCancel)
  529.     End If
  530.     bDiskInserted = (xAnswer = vbOK)
  531. End Sub
  532. '------------------------------------------------------------------------------------
  533. ' The ListingFile event is triggered for each file listed as a result of
  534. ' calling the ListZipContents method.
  535. '------------------------------------------------------------------------------------
  536. Private Sub xZip_ListingFile(ByVal sFilename As String, ByVal sComment As String, _
  537.                              ByVal lSize As Long, ByVal lCompressedSize As Long, _
  538.                              ByVal nCompressionRatio As Integer, _
  539.                              ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  540.                              ByVal lCRC As Long, ByVal dtLastModified As Date, _
  541.                              ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  542.                              ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  543.                              ByVal bEncrypted As Boolean, ByVal lDiskNumber As Long, _
  544.                              ByVal bExcluded As Boolean, _
  545.                              ByVal xReason As XceedZipLibCtl.xcdSkippingReason)
  546.     Dim sPathName  As String
  547.     Dim nBackslash As Integer
  548.     Dim xItem      As ListItem
  549.     nBackslash = InStrRev(sFilename, "\")
  550.     If nBackslash > 0 Then
  551.         sPathName = Left(sFilename, nBackslash - 1)                 ' Everything before the backslash
  552.         sFilename = Right(sFilename, Len(sFilename) - nBackslash)   ' Everything after the backslash
  553.     End If
  554.     If (xAttributes And xfaFolder) > 0 Then
  555.         sFilename = "<dir>"
  556.     End If
  557.     ' Format the information for the item and add it to the main listbox.
  558.     Set xItem = lstMain.ListItems.Add(, , sFilename)
  559.       
  560.     ' Put the file attributes information in the correct list column
  561.     xItem.SubItems(1) = sComment
  562.     xItem.SubItems(2) = lSize
  563.     xItem.SubItems(3) = lCompressedSize
  564.     xItem.SubItems(4) = Attributes(xAttributes)
  565.     xItem.SubItems(5) = Hex(lCRC)
  566.     xItem.SubItems(6) = dtLastModified
  567.     xItem.SubItems(7) = dtLastAccessed
  568.     xItem.SubItems(8) = dtCreated
  569.     xItem.SubItems(9) = sPathName
  570.     xItem.SubItems(10) = xMethod
  571.     xItem.SubItems(11) = bEncrypted
  572. End Sub
  573. '------------------------------------------------------------------------------------
  574. ' The ProcessCompleted event is triggered at the end of every operation. It gives
  575. ' you information about the operation, including the number of files processed,
  576. ' the number of files skipped, the compression ratio, and more. If an error has
  577. ' been detected in any operation, that operation will be canceled and the
  578. ' ProcessCompleted event will be triggered immediately.
  579. '------------------------------------------------------------------------------------
  580. Private Sub xZip_ProcessCompleted(ByVal lFilesTotal As Long, ByVal lFilesProcessed As Long, _
  581.                                   ByVal lFilesSkipped As Long, ByVal lBytesTotal As Long, _
  582.                                   ByVal lBytesProcessed As Long, ByVal lBytesSkipped As Long, _
  583.                                   ByVal lBytesOutput As Long, ByVal nCompressionRatio As Integer, _
  584.                                   ByVal xResult As XceedZipLibCtl.xcdError)
  585.     Dim sErrorMessage As String
  586.     sErrorMessage = xZip.GetErrorDescription(xvtError, xResult)
  587.     Select Case xZip.CurrentOperation
  588.     Case xcoZipping
  589.         frmResults.AddMessage "Zipping completed: " & sErrorMessage
  590.         lblStatusBar.Caption = "Zipping completed."
  591.     Case xcoUnzipping
  592.         frmResults.AddMessage "Unzipping completed: " & sErrorMessage
  593.         lblStatusBar.Caption = "Unzipping completed."
  594.     Case xcoRemoving
  595.         frmResults.AddMessage "Removing completed: " & sErrorMessage
  596.         lblStatusBar.Caption = "Removing completed."
  597.     Case xcoTestingZipFile
  598.         frmResults.AddMessage "Testing completed: " & sErrorMessage
  599.         lblStatusBar.Caption = "Testing completed."
  600.     End Select
  601. End Sub
  602. '------------------------------------------------------------------------------------
  603. ' The RemovingFile event is triggered when the RemoveFiles method is called. It
  604. ' gives information about each file being deleted: filename, size, etc.
  605. '------------------------------------------------------------------------------------
  606. Private Sub xZip_RemovingFile(ByVal sFilename As String, ByVal sComment As String, _
  607.                               ByVal lSize As Long, ByVal lCompressedSize As Long, _
  608.                               ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  609.                               ByVal lCRC As Long, ByVal dtLastModified As Date, _
  610.                               ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  611.                               ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  612.                               ByVal bEncrypted As Boolean)
  613.     frmResults.AddMessage "Removing " & sFilename
  614. End Sub
  615. '------------------------------------------------------------------------------------
  616. ' The SkippingFile event is triggered when a file is skipped from an adding or
  617. ' extracting operation. It does not necessarily mean that the current operation
  618. ' has caused an error. A file may be skipped due to the RequiredFile attributes,
  619. ' ExcludedFileAttributes, Min and MaxSize and Min and MaxDate.
  620. '------------------------------------------------------------------------------------
  621. Private Sub xZip_SkippingFile(ByVal sFilename As String, ByVal sComment As String, _
  622.                               ByVal sFilenameOnDisk As String, ByVal lSize As Long, _
  623.                               ByVal lCompressedSize As Long, _
  624.                               ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  625.                               ByVal lCRC As Long, ByVal dtLastModified As Date, _
  626.                               ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  627.                               ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  628.                               ByVal bEncrypted As Boolean, _
  629.                               ByVal xReason As XceedZipLibCtl.xcdSkippingReason)
  630.     frmResults.AddMessage "Skipping " & sFilename & ": " & xZip.GetErrorDescription(xvtSkippingReason, xReason)
  631. End Sub
  632. '------------------------------------------------------------------------------------
  633. ' The TestingFile event is triggered when a file is read from the zip file for
  634. ' testing. All files are listed this way. Then the unzipping test starts, and
  635. ' FileStatus and GlobalStatus are triggered.
  636. '------------------------------------------------------------------------------------
  637. Private Sub xZip_TestingFile(ByVal sFilename As String, ByVal sComment As String, _
  638.                              ByVal lSize As Long, ByVal lCompressedSize As Long, _
  639.                              ByVal nCompressionRatio As Integer, _
  640.                              ByVal xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  641.                              ByVal lCRC As Long, ByVal dtLastModified As Date, _
  642.                              ByVal dtLastAccessed As Date, ByVal dtCreated As Date, _
  643.                              ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  644.                              ByVal bEncrypted As Boolean, ByVal lDiskNumber As Long)
  645.     frmResults.AddMessage "Testing " & sFilename
  646. End Sub
  647. '------------------------------------------------------------------------------------
  648. ' The UnzipPreprocessingFile event is triggered before a file gets to the physical
  649. ' unzipping operation. It does not mean that the unzipping operation is successful.
  650. '------------------------------------------------------------------------------------
  651. Private Sub xZip_UnzipPreprocessingFile(ByVal sFilename As String, ByVal sComment As String, _
  652.                                         sDestFilename As String, ByVal lSize As Long, _
  653.                                         ByVal lCompressedSize As Long, _
  654.                                         xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  655.                                         ByVal lCRC As Long, dtLastModified As Date, _
  656.                                         dtLastAccessed As Date, dtCreated As Date, _
  657.                                         ByVal xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  658.                                         ByVal bEncrypted As Boolean, sPassword As String, _
  659.                                         ByVal lDiskNumber As Long, bExcluded As Boolean, _
  660.                                         ByVal xReason As XceedZipLibCtl.xcdSkippingReason, _
  661.                                         ByVal bExisting As Boolean, _
  662.                                         xDestination As XceedZipLibCtl.xcdUnzipDestination)
  663.     If (Not bExcluded) Then
  664.         'Adds a description line to the Results form window
  665.         frmResults.AddMessage "Unzipping " & sFilename
  666.     End If
  667. End Sub
  668. '------------------------------------------------------------------------------------
  669. ' The Warning event occurs during any operation that encounters a recoverable error.
  670. '------------------------------------------------------------------------------------
  671. Private Sub xZip_Warning(ByVal sFilename As String, ByVal xWarning As XceedZipLibCtl.xcdWarning)
  672.     frmResults.AddMessage "Warning: " & xZip.GetErrorDescription(xvtWarning, xWarning)
  673. End Sub
  674. '------------------------------------------------------------------------------------
  675. ' The ZipContentsStatus event occurs whenever a zip file needs to be read. We only
  676. ' update the progress bar while listing.
  677. '------------------------------------------------------------------------------------
  678. Private Sub xZip_ZipContentsStatus(ByVal lFilesRead As Long, ByVal lFilesTotal As Long, ByVal nFilesPercent As Integer)
  679.     If xZip.CurrentOperation = xcoListing Then
  680.         prbGlobalProgress.Value = nFilesPercent
  681.     End If
  682. End Sub
  683. '------------------------------------------------------------------------------------
  684. ' The ZipPreprocessingFile event is triggered right before a file is actually
  685. ' zipped. You can decide, in this event, whether or not you really want the file
  686. ' to be zipped (use the bExcluded parameter) or you can change some of the file's
  687. ' information before it is zipped. This event doesn't mean the file has been
  688. ' actually zipped yet.
  689. '------------------------------------------------------------------------------------
  690. Private Sub xZip_ZipPreprocessingFile(sFilename As String, sComment As String, _
  691.                                       ByVal sSourceFilename As String, ByVal lSize As Long, _
  692.                                       xAttributes As XceedZipLibCtl.xcdFileAttributes, _
  693.                                       dtLastModified As Date, dtLastAccessed As Date, _
  694.                                       dtCreated As Date, _
  695.                                       xMethod As XceedZipLibCtl.xcdCompressionMethod, _
  696.                                       bEncrypted As Boolean, sPassword As String, _
  697.                                       bExcluded As Boolean, _
  698.                                       ByVal xReason As XceedZipLibCtl.xcdSkippingReason, _
  699.                                       ByVal bExisting As Boolean)
  700.     'Adds a description line to the Results form window if the
  701.     'file is not excluded from the zipping operation
  702.     If (Not bExcluded) Then
  703.         frmResults.AddMessage "Zipping " & sFilename
  704.     End If
  705. End Sub
  706. '------------------------------------------------------------------------------------
  707. ' Disable all options while processing. Enable the abort button and show the
  708. ' progress bar.
  709. '------------------------------------------------------------------------------------
  710. Public Sub DisableInterface()
  711.     ' Disable menu items
  712.     frmMain.mnuFile.Enabled = False
  713.     frmMain.mnuActions.Enabled = False
  714.     frmMain.mnuHelp.Enabled = False
  715.     ' Activate the Abort button and show the progress bar
  716.     cmdAbort.Enabled = True
  717.     prbGlobalProgress.Visible = True
  718.     lblProgress.Visible = True
  719. End Sub
  720. '------------------------------------------------------------------------------------
  721. ' Enable options depending on current state (zip file opened or not), disable abort
  722. ' button and hide progress bar.
  723. '------------------------------------------------------------------------------------
  724. Public Sub EnableInterface()
  725.     frmMain.mnuActions.Enabled = (Len(xZip.ZipFilename) > 0)
  726.     frmMain.mnuFile.Enabled = True
  727.     frmMain.mnuHelp.Enabled = True
  728.     'Deactivate the Abort button and hide the progress bar
  729.     cmdAbort.Enabled = False
  730.     prbGlobalProgress.Visible = False
  731.     lblProgress.Visible = False
  732. End Sub
  733. '------------------------------------------------------------------------------------
  734. ' Ask the user to confirm the removal of the selected files.
  735. '------------------------------------------------------------------------------------
  736. Private Function ConfirmRemoveFiles() As Boolean
  737.     Dim xAnswer As VbMsgBoxResult
  738.     xAnswer = MsgBox("The selected file(s) will be removed from the zip file. Continue?", vbOKCancel)
  739.     If xAnswer = vbOK Then
  740.         xZip.ProcessSubfolders = False
  741.         xZip.FilesToProcess = GetSelectedFiles(lstMain.ListItems, True)
  742.     End If
  743.     ConfirmRemoveFiles = (xAnswer = vbOK)
  744. End Function
  745.